package com.jf.jsp.utils;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-09-01
 * Time:0:16
 */
public class WebUtil {
    public static String[] getWarnings(String num1, String num2, String operator) {
        String[] ret = new String[3];
        if (!isInteger(num1)) {
            ret[0] = num1 + " is not a number";
        }
        if (!isInteger(num2)) {
            ret[1] = num2 + " is not a number";
        }
        if (operator == null || !(operator.equals("+") || operator.equals("-") || operator.equals("*") || operator.equals("/"))) {
            ret[2] = operator + " is not a valid operator";
        }
        return ret;
    }
    private static boolean isInteger(String str) {
        String regex = "^-?([1-9]\\d*|0)$";
        return str.matches(regex);
    }
}
